import {JsonController,Controller, Render, Get, UseBefore, Session,Req,Res,Ctx,QueryParams,UseInterceptor,Post,Body,UploadedFiles, Params,} from "routing-controllers";
import { config } from "../../config";
import { Service, Inject } from "typedi";
import {TopicServiceImpl} from '../../service/impl/TopicServiceImpl'
import TokenLoginMiddlewares from '../../middleware/TokenLoginMiddlewares';
import { JsonResponseInterceptor } from "../../middleware/JsonResponseMiddlewares";
import {TopicModel,SubModel,getIndexTpoic} from '../../model/TopicModel'

@Service()
@JsonController(`${config.apiurl}/v1/topic`)
@UseInterceptor(JsonResponseInterceptor)
@UseBefore(TokenLoginMiddlewares)
export class TopicControllerApi {

  static _userType:string|object;


    @Inject()
    private TopicServiceImpl!:TopicServiceImpl;


    @Get("/topicContent")
    public async topicContent (@Res() response: any,@Req() request:any, @Session() session:any,@QueryParams()Params:TopicModel): Promise<any> {
        return await this.TopicServiceImpl.topicContent(Params);
    }

    @Get("/changeSubTopic")
    public async changeSubTopic (@Res() response: any,@Req() request:any, @Session() session:any,@QueryParams()Params:SubModel): Promise<any> {

        return await this.TopicServiceImpl.changeSubTopic(Params);
    }

    @Get("/getAllTagClass")
    public async getAllTagClass (@Res() response: any,@Req() request:any, @Session() session:any): Promise<any> {

        return{tagClassList: await this.TopicServiceImpl.getAllTagClass()};
    }

    @Get("/getIndexAllTopic")
    public async getIndexAllTopic (@Res() response: any,@Req() request:any, @Session() session:any,@QueryParams()Params:getIndexTpoic): Promise<any> {

        return{tagList: await this.TopicServiceImpl.getIndexAllTopic(Params)};
    }

  }

  